﻿@{
    Layout = "_Layout";
    ViewData["Title"] = "资产维修记录";
}

<el-container>
    <avue-crud :data="tableData" :option="option" :permission="hasPermission" :page.sync="pageOption" :table-loading="loading"
               v-on:refresh-change="refreshChange"
               v-on:row-save="handleRowSave"
               v-on:row-update="handleRowUpdate"
               v-on:row-del="handleRowDel"
               v-on:search-change="searchChange"
               v-on:search-reset="resetChange"
               v-on:on-load="onLoad">
        <template slot="record" slot-scope="scope">
            <modify-record :data="scope.row"></modify-record>
        </template>
    </avue-crud>
</el-container>

@section Scripts {
    <script>
        new Vue({
            el: '#app',
            mixins: [curdMixin],
            data() {
                return {
                    name: "records",
                    pageUrl: `/records/pages`,
                    addUrl: `/records/add`,
                    editUrl: `/records/update`,
                    deleteUrl: `/records/delete`,

                    option: {
                        searchShowBtn: Permissions.avePermission(`records:searchBtn`),
                        refreshBtn: Permissions.avePermission(`records:searchBtn`),
                        menuWidth: '350',
                        rowKey: 'id',
                        searchShow: true,
                        column: [
                            { prop: "id", label: `${this.i18n.t('primary_key')}`, search: false, hide: true, type: "number", display: false, showColumn: false },
                            // {
                            //     prop: "assetId",
                            //     label: `资产ID`,
                            //     search: true,
                            //     hide: false,
                            //     type: "number",
                            //     rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }]
                            // },
                            {
                                prop: "assetId",
                                label: `资产`,
                                search: true,
                                type: "select",
                                dicUrl: `/assets/list`,
                                props: { label: "name", value: "id" },
                                rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseselect')}` }]
                            },
                            {
                                prop: "order",
                                label: `维修单号`,
                                search: true,
                                hide: false,
                                width: '120',
                                rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }]
                            },
                            {
                                prop: "date",
                                label: `维修日期`,
                                search: true,
                                hide: false,
                                type: "date",
                                format: "yyyy-MM-dd",
                                valueFormat: "yyyy-MM-dd",
                                rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }]
                            },
                            {
                                prop: "company",
                                label: `维修公司`,
                                search: true,
                                hide: false,
                                width: '150'
                            },
                            {
                                prop: "cost",
                                label: `维修金额`,
                                search: false,
                                hide: false,
                                type: "number",
                                precision: 2,
                                min: 0,
                                width: '100'
                            },
                            {
                                prop: "hours",
                                label: `维修工时(小时)`,
                                search: false,
                                hide: false,
                                type: "number",
                                step: 0.5,
                                min: 0,
                                rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }],
                                width: '120'
                            },
                            {
                                prop: "content",
                                label: `维修内容`,
                                search: false,
                                hide: false,
                                type: "textarea",
                                span: 24,
                                minRows: 2,
                                rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }]
                            },
                            {
                                prop: "maintenanceType",
                                label: `维护类型`,
                                search: true,
                                hide: false,
                                type: "select",
                                dicData: [
                                    { label: "预防性维护", value: "Preventive" },
                                    { label: "纠正性维护", value: "Corrective" },
                                    { label: "预测性维护", value: "Predictive" },
                                    { label: "改进性维护", value: "Improvement" },
                                    { label: "校准维护", value: "Calibration" },
                                    { label: "季节性维护", value: "Seasonal" },
                                    { label: "大修", value: "Overhaul" }
                                ],
                                rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }],
                                width: '120'
                            },
                            {
                                prop: "person",
                                label: `验收人员`,
                                search: true,
                                type: "select",
                                dicUrl: `/assets/getsysuserlist`,
                                dicMethod: 'get',
                                props: { label: "nickName", value: "id" },
                                rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }]
                            },
                       
                            { prop: "record", label: `${this.i18n.t('modification_record')}`, slot: true, display: false, showColumn: false, width: 140, align: `center` },
                        ],
                    },
                }
            },
            created() {
                this.selectRow = {};
            },
            methods: {
                // 可以添加自定义方法
            }
        });
    </script>
}